<?php
HBase::using('Backend.*');
HBase::using('DAL.*');
class backend_usersroles_index extends HModule {
	public $data;
	public $page;
	function run(){
		if (isset($_POST['flag'])) {
    		self::process();    	
	    }
	    
	    // Get the current table page
		if (!isset($_GET['page'])){
			$this->page = 1;
		}else {
			$this->page = HCommon::xss($_GET['page']);
		}
		
		// get Paged Data
		$this->data = HUsersRoles::getAllRolesExceptAdmin();
	}
	
	function process(){
		$roleName 	= $_POST['tbxRoleName'];
		if (HUsersRoles::insert($roleName)) {
			HUtil::alert("Add role successfully!");
		}else {
			HUtil::alert("ERROR: Add role unsuccessfully! ");
		}
		HUtil::redirect(HCommon::navigateUrl('UsersRoles'));
	}
}
?>